﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PaceR.Core.EntityStorage
{
    /// <summary>
    /// Stores data in an in memory dictionary
    /// </summary>
    public sealed class SimpleStore : EntityStore
    {
        private readonly Dictionary<string, object> data;

        public SimpleStore()
        {
            data = new Dictionary<string, object>();
        }

        protected override object GetEntity(string storageKey)
        {
            object val = null;
            data.TryGetValue(storageKey, out val);
            return val;
        }

        protected override void SaveEntity(string storageKey, object entity)
        {
            data[storageKey] = entity;
        }

        protected override void ClearEntity(string storageKey)
        {
            data.Clear();
        }
    }
}
